<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<form [formGroup]="form" *ngIf="form" (ngSubmit)="onClose()">
  <h2 mat-dialog-title class="title">Change the subscription end date</h2>

  <mat-dialog-content class="change-end-date__dialog-content">
    <div class="change-end-date__content">
      <div class="change-end-date__warning">
        Be careful, by changing the end date, {{ data.applicationName }} may no longer have access to this API.
      </div>
      <div *ngIf="data.securityType === 'API_KEY'">All API Keys after the new end date will be revoked.</div>
      <mat-form-field>
        <mat-label>Validation end date (optional)</mat-label>
        <input matInput [owlDateTime]="endDate" [min]="minDate" formControlName="endDate" />
        <mat-icon [owlDateTimeTrigger]="endDate" matSuffix svgIcon="gio:calendar"></mat-icon>
        <owl-date-time #endDate></owl-date-time>
        <mat-error *ngIf="form.get('endDate').hasError('owlDateTimeMin')">
          Date Time value must be after {{ minDate | date: 'medium' }}
        </mat-error>
      </mat-form-field>
    </div>
  </mat-dialog-content>
  <mat-dialog-actions class="actions">
    <button mat-flat-button type="button" [mat-dialog-close]="undefined">Cancel</button>
    <button
      color="primary"
      type="submit"
      mat-raised-button
      aria-label="Change end date of subscription"
      [disabled]="form.invalid || form.pristine"
    >
      Change end date
    </button>
  </mat-dialog-actions>
</form>
